package com.example.service.serviceImple;

import com.example.dao.ArticalDao;
import com.example.entity.Article;
import com.example.entity.Type;
import com.example.entity.vo.ArticleVo;
import com.example.entity.vo.SearchVO;
import com.example.service.ArticalService;
import com.example.util.BeanFactroy;

import java.util.Date;
import java.util.List;

public class ArticalServiceImpl implements ArticalService {

    private ArticalDao articaldao =  BeanFactroy.createBean(ArticalDao.class);

    @Override
    public Article QueryArticalById(Long articleId) {
        return articaldao.findArticleByArticalId(articleId);
    }

    @Override
    public List<ArticleVo> QueryArticalByUserId(Long articalId) {
        return articaldao.findArticleByUserId(articalId);
    }

    @Override
    public List<Article> QueryAllArticalByUserId(Long userId) {
        return articaldao.findAllArticleByUserId(userId);
    }

//    @Override
//    public int differTime(Long articleId) {
//        return articaldao.differTime(articleId);
//    }

    @Override
    public List<Article> queryArticalByBlur(String str) {
        return articaldao.findArticalByBlur(str);
    }

    @Override
    public int addArticle(Article article) {
        article.setCreateTime(new Date());
        article.setUpdateTime(new Date());
        return articaldao.addArticle(article);
    }

    @Override
    public int isLieks(Long userId, Long articalId) {
        return articaldao.isLikes(userId,articalId);
    }

    @Override
    public List<Article> queryHotArtical(long type) {

        return articaldao.queryHotArtical(type);
    }

    @Override
    public List<Type> queryType() {
        return articaldao.queryType();
    }

    @Override
    public List<Article> queryHotTitle() {
        return articaldao.queryHotTitle();
    }

    @Override
    public List<Article> SearchByKey(String key) {
        return articaldao.SearchByKey(key);
    }

    @Override
    public int isCollect(Long userId, Long authorId) {
        return articaldao.isCollect(userId,authorId);
    }

    @Override
    public List<Article> queryColletedByUserId(long userId) {
        List<Article > articleList =  articaldao.queryColletedByUserId(userId);
        return articleList;
    }

    @Override
    public int updateColletion(long userId, long articleId) {
        return articaldao.updateColletionByUserIdArticleId(userId,articleId);
    }


    @Override
    public int addColletion(long userId, long articleId) {
        return articaldao.addColletionByUserIdArticleId(userId,articleId);
    }

    @Override
    public int deleteById(long id) {
        return articaldao.deleteById(id);
    }


    @Override
    public int addLikes(Long userId,Long articalId) {
        return articaldao.addLikes(userId,articalId);
    }

    @Override
    public int reduceLikes(Long userId,Long articleId) {
        return articaldao.reducedLikes(userId,articleId);
    }
}
